package aes.gui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.CardLayout;
import java.awt.Font;
import javax.swing.JButton;

import aes.general.StudentControl;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JSeparator;

/**
 * This panel is intended for the students who are making the 
 * manual exam. It show the students a short explanation and the 
 * option to download the exam file to their system to begin.  
 */
public class StudentMakeExamManualPane extends JPanel {
/**
 * 
 */

	private static final long serialVersionUID = 1L;
	private JPanel jp;
	private String ActivationCode;

	/**
	 * Create the panel.
	 * 
	 * @param contentPane
	 *            the content pane
	 * @param Code
	 *            the exam activation code
	 */
	public StudentMakeExamManualPane(JPanel contentPane,String Code) {
		this.jp = contentPane;
		this.ActivationCode=Code;
		setLayout(new CardLayout(0, 0));
		
		JPanel DownloadPane = new JPanel();
		add(DownloadPane, "DownloadPane");
		DownloadPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Click Download button to get Exam file , then save it to your Computer.\r\n");
		lblNewLabel.setFont(new Font("Dialog", Font.BOLD, 13));
		lblNewLabel.setBounds(56, 130, 515, 44);
		DownloadPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("When your download begins, your exam time countdown will start.");
		lblNewLabel_1.setFont(new Font("Dialog", Font.PLAIN, 13));
		lblNewLabel_1.setBounds(65, 220, 419, 21);
		DownloadPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("Click the download button when you ready!");
		lblNewLabel_2.setFont(new Font("Dialog", Font.PLAIN, 13));
		lblNewLabel_2.setBounds(65, 252, 336, 34);
		DownloadPane.add(lblNewLabel_2);
		
		JLabel lblNewLabel_3 = new JLabel("Good Luck!");
		lblNewLabel_3.setFont(new Font("Dialog", Font.PLAIN, 13));
		lblNewLabel_3.setBounds(257, 324, 89, 21);
		DownloadPane.add(lblNewLabel_3);
		
		JButton downloadBtn = new JButton("Download ");
		downloadBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				DownloadExam();		
			}
		});
		downloadBtn.setBounds(317, 454, 123, 23);
		DownloadPane.add(downloadBtn);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(10, 38, 620, 2);
		DownloadPane.add(separator);
		
		JLabel lblStartManualExam = new JLabel("Start Manual Exam");
		lblStartManualExam.setFont(new Font("Tempus Sans ITC", Font.BOLD, 21));
		lblStartManualExam.setBounds(203, 11, 234, 29);
		DownloadPane.add(lblStartManualExam);
		
		JButton button = new JButton("Back");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				CardLayout cl = (CardLayout)(jp.getLayout());
				 cl.show(jp,"MainPanel");
			}
		});
		button.setBounds(150, 454, 129, 23);
		DownloadPane.add(button);
		
		JPanel SubmitPane = new JPanel();
		add(SubmitPane, "SubmitPane");
		SubmitPane.setLayout(null);
	}

	protected void DownloadExam() {
		StudentControl.DownloadExamQuery(ActivationCode);	
	}
}
